home *** CD-ROM | disk | FTP | other *** search
/ El Mac 1 / Magazine.iso / EL MAC 1 / Shareware / HyperCard / XCMD Docs / CompileIt! Source Code / ImageCards divFactor < prev    next >
Encoding:
Text File  |  1995-10-01  |  1.7 KB  |  46 lines  |  [TEXT/ttxt]

  1. global rect:R[8] -- rect will default to 0,0,0,0 ($00000000 $00000000)
  2. on ImageCards divFactor
  3.   getPort oldPort
  4.   put newPtr(512) into newPort
  5.   openCPort newPort
  6.   setPort oldPort
  7.   put oldPort@.portrect.topLeft into rect.topLeft
  8.   put oldPort@.portrect.botRight into rect.botRight
  9.   localtoGlobal rect.topLeft
  10.   localToGlobal rect.botRight
  11.   setPort newPort
  12.   movePortTo rect.topLeft.integerType[1],rect.topLeft.integerType[2]
  13.   if divFactor="" or divFactor=0 or divFactor is not a number then
  14.     setRect rect,0,0,64,43
  15.   else
  16.     -- calculate pict rect.
  17.     --   how big is the card window?
  18.     --     remember rects are backwards points.
  19.     setRect rect,0,0,the round of ((oldPort@.portRect.botRight.integerType[2]-oldPort@.portRect.topLeft.integerType[2])/divFactor),the round of ((oldPort@.portRect.botRight.integerType[1]-oldPort@.portRect.topLeft.integerType[1])/divFactor)
  20.   end if
  21.   setPort newPort
  22.   repeat the number of cds
  23.     SendCardMessage ("Doingcard" && the number of this card)
  24.     if commandPeriod() then exit repeat
  25.     setPort newPort
  26.     copyBits oldPort@.PortBits,newPort@.portbits,oldPort@.portRect,rect,ditherCopy,NIL
  27.     put openPicture(rect) into myPict
  28.     copyBits newPort@.portBits,newPort@.portBits,rect,rect,0,NIL
  29.     closePicture
  30.     get GetNamedResource("PICT",the id of this card)
  31.     if it≠0 then
  32.       rmveResource it
  33.       disposHandle it
  34.     end if
  35.     AddResource myPict,"PICT",uniqueID("PICT"),the id of this card
  36.     WriteResource myPict
  37.     releaseResource myPict
  38.     setPort oldPort
  39.     go next card
  40.     if value("the lockScreen") then unlock screen
  41.   end repeat
  42.   UpdateResFile curresFile()
  43.   closeCPort newPort
  44.   setPort oldPort
  45.   disposPtr newPort
  46. end ImageCards